For This Assignment You Will…

Practice witing code that uses interacting classes to create an adventure game.

Create an Adventure Game

You will be given three classes: Treasure , Player , and Room and you will write the Game class. The Treasure class has object attributes of name and points . The Player class has object attributes of name , treasure_list , and location ( Room ) and methods points() and choose_dir() . The Room class has object attributes of name , treasure_list , and dir_dictionary . The Room class also has a method transfer_treasure(Player) that transfers all treasure from the room to a Player object and an add_dir(dir,room) which adds the passed direction and room to the dir_dictionary .

You will be given a file (see bottom of this step under the heading ‘See also’) with three classes: Treasure , Player , and Room and you will write the Game class. The Treasure class has object attributes of name and points . The Player class has object attributes of name , treasure_list , and location ( Room ) and methods points() and choose_dir() . The Room class has object attributes of name , treasure_list , and dir_dict . The Room class also has a method transfer_treasure(self, player) that transfers all treasure from the room to a Player object and a set_dir_dict method which sets the room’s dir_dict to the passed dictionary.

Follow the Steps Below to Complete the Assignment

A. You will write a Game class that does the following in the constructor:

B. You will also write the play method in the Game class to do the following.

It is a good idea to create a map of your rooms. This will make it easier to both set up the game and play it. You can also add additional features such as a magic word that takes the Player directly to the exit room (the original game used XYZZY). In the map below the player may start in the Hall and then move south to the Library. The game will print “You are in the Library with: Lamp (10) and Picture (5)” , and transfer the treasure objects to the player. The player’s would now have a total of 15 points. If the player moved east to the bedroom the player would get the necklace and ring and so would have a total of 45 points. If the game required at least 50 points the game should print, “You found the exit room but do not have enough points to win.” The player would have to go back west to the library and south to the kitchen to gather the last treasure and then go back to the bedroom to win.

Self-assessment and peer review criteria are listed below. For a more detailed version, please download and view the attached rubric.

  1. Had four or more rooms

  2. Game constructor met the requirements of Room objects, dir_dictionary , Treasure objects, Player object exit_room, and win_points

  3. Game play method met all the requirements

What to submit?

Submit your code in a .pdf or .docx file using the Gallery Tool. The Gallery Tool launches from a course item that is labeled as an “LTI Item.” (You'll see it in the next section.)

Accessing the Gallery

When you click “LTI Item” in Coursera, the course item screen will open. To access the Gallery, you must first agree to the acceptable use policy. You can then launch the tool as a “Learner” by clicking on the blue “Open Tool” button. The Gallery will open in a new tab in your internet browser.

Note: The first time you launch the Gallery Tool, you will be asked to set up your Gallery profile by providing some basic information and selecting your sharing settings. After completing your profile, you will be redirected to the main screen of the Gallery.

Submitting your file to the Gallery

On the left side of the screen, click “ Upload Submission ” and fill out the required information:

Navigating the Gallery

Scroll through the submissions to see the various examples that your peers have shared. You can also sort the examples by using the available filters near the top right-hand corner of the Gallery. As you explore the submissions, we encourage you to leave comments and feedback on the submissions you view.

To leave comments on submissions you browse, click on the tile of the submission. After reviewing the details of the submission, scroll down to the “Comments” text field. Type your comments, general feedback, and thoughts on the submitter’s questions in this field. When finished, click on the blue “Post comment” button at the bottom left-hand corner of the page to share your comments.